<template>
  <div class="userList">
    <div>
      <div style="width: 300px">
        <el-input
          placeholder="请输入账号"
          v-model="userQuery.account"
          size="small"
          class="input-with-select"
          clearable
        >
          <el-button
            slot="append"
            icon="el-icon-search"
            @click="getUser()"
          ></el-button>
        </el-input>
      </div>
    </div>
    <el-table
      ref="multipleTable"
      :data="userList"
      tooltip-effect="dark"
      style="width: 100%"
      row-key="id"
      size="mini"
    >
      <el-table-column width="55" label="选择">
        <template slot-scope="scope">
          <el-radio
            :label="scope.row.id"
            v-model="value"
            @change.native="getTemplateRow(scope.row)"
          >
            {{ scope.row.name }}
           
          </el-radio>
        </template>
      </el-table-column>
      <el-table-column prop="userName" label="用户">
        <template slot-scope="scope">{{ scope.row | showUserInfo }}</template>
      </el-table-column>
      <el-table-column prop="deptFullName" label="部门">
        <template slot-scope="scope">{{
          scope.row.deptFullName | deptFormat
        }}</template>
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间" width="200px">
      </el-table-column>
    </el-table>
    <Pagination
      style="margin-top: 20px"
      v-show="parseInt(pageObj.count) > 0"
      :total="parseInt(pageObj.count)"
      @change="getUser"
      :page.sync="userQuery.page"
      :limit.sync="userQuery.limit"
    />
  </div>
</template>
<script>
import { tbSysUserQuery } from "@/api/admin/user/user-manage.js";
import Bus from "@/utils/bus.js";
export default {
  data() {
    return {
      value: "",
      userQuery: {
        page: 1,
        limit: 10,
        account: "",
      },
      pageObj: {},
      userList: [],
    };
  },
  props: ["userId"],
  mounted() {
      
    if (this.userId.length) {
      this.value = this.userId[0].id;
    }
    this.getUser();
  },
  watch: {},
  methods: {
    getTemplateRow(row) {
      Bus.$emit("setGrantUser", row);
    },
    //获取人员
    getUser() {
      tbSysUserQuery(this.userQuery).then((res) => {
        if (res.data.code == 0) {
          this.pageObj = res.data;
          this.userList = res.data.data;
        }
      });
    },
  },
};
</script>